/**
 * Yolema.com Inc.
 * Copyright (c) 2011-2012 All Rights Reserved.
 */
package org.grayrabbit.pay.core.model.utils;

import org.grayrabbit.pay.core.model.exception.PayException;

/**
 * 支付平台数据验证工具类
 * 
 * @author wy
 * @version $Id: PayAssertUtil.java, v 0.1 2012-6-8 上午11:22:49 wy Exp $
 */
public class PayAssertUtil {

    /**参数异常*/
    private static final String ASSERT_PARAM_ERROR = "PARAM_ERROR";

    /**
     * 不能为空
     * 
     * @param obj
     * @param message
     */
    public static void notNull(Object obj, String message) {
        if (obj == null) {
            throw new PayException(ASSERT_PARAM_ERROR, message);
        }
    }

    /**
     * 字符串不能为空
     * 
     * @param str
     * @param message
     */
    public static void notEmpty(String str, String message) {
        if (str == null || str.trim().length() == 0) {
            throw new PayException(ASSERT_PARAM_ERROR, message);
        }
    }
    
    /**
     * 表达式验证
     * 
     * @param condition
     * @param message
     */
    public static void isTrue(boolean condition,String message){
        if(!condition){
            throw new PayException(ASSERT_PARAM_ERROR, message);
        }
    }

}
